#include <stdio.h>
#include <stdlib.h>
/*int compare(int a[], int size,int remaining){
    int count=0;
    for (int i=0; i<size;i++){
        int num=a[i];
        if (num==remaining){
            count++;
            continue;
        }
        if (num>remaining){continue;}
        if (i==size-1){break;}
        else{
            int *b=a+(i+1);
            int count2=compare(b,size-i-1,remaining-num);
            count+=count2;
        }
    }
    return count; 
}*/

int a[20];
int compare(int n,int remaining){
	if(remaining==0) return 1;		
	if(n<=0) return 0;		 
	return compare(n-1,remaining)+compare(n-1,remaining-a[n-1]);	
}
    
    /*for (int i=0; i<=remaining; i++) {
        for (int j=0; j<=n; j++) {
            printf("%d ",b[i][j]);
        }
        printf("\n");
    }
    printf("1");*/




void main(){
    int time=0;
    int n;
    int num=0;
    
    while(scanf("%d",&n)!=EOF){
        if (time==0){num=n;}
        else{
            a[time-1]=n;
        }
        if (time==num){
            time=0;
            int count=compare(num,40);
            printf("%d",count);
            printf("\n");
           
            continue;
        }

        time+=1;
    }


}